﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Data.Api.Repositories;
using Data.Api.Db;

namespace Shop.Managers
{
    public class ManagerCategory : IManagerCategory
    {
        private ICategoriesRepository repository;
        private IShopContext context;

        public ManagerCategory(ICategoriesRepository repository, IShopContext context)
        {
            this.repository = repository;
            this.context = context;
        }

        public void Add(Entity.Categories.Category category)
        {
            repository.Insert(category);
            context.Commit();
        }

        public void Update(Entity.Categories.Category category)
        {
            repository.Update(category);
            context.Commit();
        }

        public void Remove(int id)
        {
            repository.Delete(id);
            context.Commit();
        }


        public IQueryable<Entity.Categories.Category> All
        {
            get { return repository.All; }
        }


        public Entity.Categories.Category Find(int id)
        {
            return repository.Find(id);
        }
    }
}